counter = 0;
distance = 1000;
distance_percentage = 1000;
distance_mat = [];
while mean(abs(distance_percentage-1)) > 0.001 && counter < 600 %max(abs(distance_percentage-1))>0.005 || 
sim_exports_wages_parallel
distance = total_income_vec - GDP_vec; 
distance_percentage = total_income_vec ./ GDP_vec;
average_dollar_distance = mean(abs(distance))
max_percentage_distance = max(abs(distance_percentage-1))
metric = mean(abs(distance_percentage-1))
distance_mat = [distance_mat; distance];
if average_dollar_distance > 1e8
GDP_guesses = GDP_vec+0.5*(total_income_vec-GDP_vec);
    if counter > 50
    GDP_guesses = GDP_vec+0.1*(total_income_vec-GDP_vec);  
    end
elseif average_dollar_distance > 5e7
    if counter < 50
    GDP_guesses = GDP_vec+0.1*(total_income_vec-GDP_vec); 
    elseif counter < 100
    GDP_guesses = GDP_vec+0.01*(total_income_vec-GDP_vec);   
    else
    counter = 600;
    end
else 
    if counter < 100
    GDP_guesses = GDP_vec+0.005*(total_income_vec-GDP_vec);   
    else
    counter = 600;
    end
end
wage_guesses = GDP_guesses./L_vec;
wage_guess_mat = repmat(wage_guesses,n_varieties_ag,1);
wage_guess_mat_3D = repmat(wage_guess_mat,1,1,n_countries);
counter = counter+1
end
if counter > 599
    disp('DID NOT CONVERGE')
end